<template>
  <div>
    <div class="common_form_search">
      <el-form ref="searchForm" :rules="rules" :inline="true" :model="searchForm">
        <el-form-item label="姓名" prop="name">
          <el-input v-model="searchForm.name" placeholder="请输入姓名" clearable />
        </el-form-item>
        <el-form-item label="电话" prop="phone">
          <el-input v-model="searchForm.phone" placeholder="请输入电话" clearable />
        </el-form-item>
        <el-form-item label="身份证号" prop="ident_number">
          <el-input v-model="searchForm.ident_number" placeholder="请输入身份证号" clearable />
        </el-form-item>
        <el-form-item label="市场价" prop="amount">
          <el-input v-model="searchForm.amount" placeholder="请输入市场价" clearable />
        </el-form-item>
        <el-form-item>
          <el-button size="small" type="primary" @click="search()">查询</el-button>
          <el-button size="small" @click="reset()">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-divider />
    <div class="flex align-center table-top-btns">
      <h5 class="flex align-center">
        <svg-icon style="margin-right:15px" icon-class="list" :size="15" />查询结果
      </h5>
    </div>
    <div class="result-box" v-show="searchResult">
      <div>结果：{{ searchResult }}</div>
    </div>
  </div>
</template>

<script>
import { getSQCreditData } from '@/api/order'

export default {
  data() {
    return {
      searchForm: {
        name: '',
        phone: '',
        ident_number: '',
        amount: '',
      },
      routerName: '',
      searchResult: '',
      rules: {
        name: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
        phone: [{ required: true, message: '请输入电话', trigger: 'blur' }],
        ident_number: [{ required: true, message: '请输入身份证号', trigger: 'blur' }],
        amount: [{ required: true, message: '请输入市场价', trigger: 'blur' }],
      },
    }
  },
  created() {
    if (this.$route.query.shopname) {
      this.routerName = this.$route.query.shopname
    }
  },
  methods: {
    // 查询
    search() {
      this.$refs['searchForm'].validate((valid) => {
        if (valid) {
          getSQCreditData(this.searchForm).then((res) => {
            this.searchResult = res
          })
        } else {
          this.$message({
            message: '请填写完整的查询条件',
            type: 'error',
          })
          return false
        }
      })
    },
    // 重置
    reset() {
      this.searchForm = {
        name: '',
        phone: '',
        ident_number: '',
        amount: '',
      }
      this.routerName = ''
      this.searchResult = ''
      this.$refs['searchForm'].resetFields()
    },
  },
}
</script>

<style lang="scss" scoped>
</style>
